package top.drinyeit.weilong.presenter;

import java.util.List;
import java.util.Map;

import top.drinyeit.weilong.activity.ChildrenOrderActivity;
import top.drinyeit.weilong.model.ChildrenOrderBean;
import top.drinyeit.weilong.retrofit.HttpResponse;
import top.drinyeit.weilong.retrofit.RetrofitMethod;
import top.drinyeit.weilong.retrofit.subscriber.CommonSubscriber;
import top.drinyeit.weilong.retrofit.subscriber.SubscriberListener;

import static top.drinyeit.weilong.app.Constant.COMMON_SUCCESS;

/**
 * Created by wu on 2018/1/11.
 */

public class ChildrenOrderPresenter {
    private ChildrenOrderActivity activity;
    public ChildrenOrderPresenter(ChildrenOrderActivity activity){
        this.activity = activity;
    }
    //获取子订单列表
    public void getChildrenOrderList(Map<String,Object> map) {
        activity.showLoading();
        CommonSubscriber<HttpResponse<List<ChildrenOrderBean>>> subscriber = new CommonSubscriber<>(new SubscriberListener<HttpResponse<List<ChildrenOrderBean>>>() {
            @Override
            public void onError(String e, int code) {
                activity.dismissLoading();
                activity.showToastMsg("错误，请重新操作！");
            }

            @Override
            public void onNext(HttpResponse<List<ChildrenOrderBean>> o) {
                activity.dismissLoading();
                if (o.getCode() == COMMON_SUCCESS) {

                }
            }
        });
        RetrofitMethod.getInstance().getChildrenOrderList(subscriber, map);
    }
}
